<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="联系人姓名" prop="telName">
        <el-input
          v-model="queryParams.telName"
          placeholder="请输入联系人姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="客户名称" prop="customerName">
        <el-input
          v-model="queryParams.customerName"
          placeholder="请输入客户名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系人编号" prop="telNo">
        <el-input
          v-model="queryParams.telNo"
          placeholder="请输入联系人编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="职务" prop="position">
        <el-input
          v-model="queryParams.position"
          placeholder="请输入职务"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手机" prop="telephone">
        <el-input
          v-model="queryParams.telephone"
          placeholder="请输入手机"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="销售负责人" prop="staffFollower">
        <el-input
          v-model="queryParams.staffFollower"
          placeholder="请输入销售负责人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['crm:person:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['crm:person:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['crm:person:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['crm:person:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="personList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
            <el-table-column label="联系人姓名" align="center" prop="telName" >
                          <template slot-scope="scope">
                            <el-button
                              size="mini"
                              type="text"
                              @click="getContactInfo(scope.row)"
                              v-hasPermi="['system:person:list']"
                            >{{scope.row.telName}}</el-button>
                          </template>
            </el-table-column>
            <el-table-column label="客户名称" align="center" class-name="small-padding fixed-width" prop="customerName">
                    <template slot-scope="scope">
                      <el-button
                        size="mini"
                        type="text"
                        @click="getCustomerInfo1(scope.row)"
                        v-hasPermi="['system:person:list']"
                      >{{scope.row.customerName}}</el-button>
                    </template>
            </el-table-column>
      <el-table-column label="联系人编号" align="center" prop="telNo" />
      <el-table-column label="职务" align="center" prop="position" />
      <el-table-column label="手机" align="center" prop="telephone" />
      <el-table-column label="销售负责人" align="center" prop="staffFollower" />
      <el-table-column label="修改时间" align="center" prop="updateTime" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['crm:person:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['crm:person:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

<el-dialog :title="title" :visible.sync="contactDialog" width="800px" append-to-body>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="联系人" name="conFirst">
      <el-collapse v-model="activeNames" @change="handleChange">
        <el-collapse-item title="联系人详情" name="con1">
          <el-form ref="ContactByTelName" :model="ContactByTelName" :rules="rules" label-width="80px">
            <el-descriptions class="margin-top"  :column="2" :size="size" border>
                    <el-descriptions-item >
                      <template slot="label">
                            联系人编号
                      </template>
                      {{ContactByTelName.telNo}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            联系人姓名
                      </template>
                      {{ContactByTelName.telName}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            联系人称谓
                      </template>
                      {{ContactByTelName.conSex}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            客户名称
                      </template>
                      {{ContactByTelName.customerName}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            联系人手机
                      </template>
                      {{ContactByTelName.telephone}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            联系人职务
                      </template>
                      {{ContactByTelName.position}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            销售负责人
                      </template>
                      {{ContactByTelName.staffFollower}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            办公电话
                      </template>
                      {{ContactByTelName.officePhone}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            Email
                      </template>
                      {{ContactByTelName.conEmail}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            修改时间
                      </template>
                      {{ContactByTelName.updateTime}}
                    </el-descriptions-item>
            </el-descriptions>
          </el-form>
        </el-collapse-item>

        <el-collapse-item title="地址信息" name="con2">
          <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                      <el-descriptions class="margin-top"  :column="2" :size="size" border>
                              <el-descriptions-item >
                                <template slot="label">
                                      国家
                                </template>
                                {{CustomerInfo.country}}
                              </el-descriptions-item>
                              <el-descriptions-item >
                                <template slot="label">
                                      省份
                                </template>
                                {{CustomerInfo.province}}
                              </el-descriptions-item>
                              <el-descriptions-item >
                                <template slot="label">
                                      城市
                                </template>
                                {{CustomerInfo.city}}
                              </el-descriptions-item>
                              <el-descriptions-item >
                                <template slot="label">
                                      区域
                                </template>
                                {{CustomerInfo.region}}
                              </el-descriptions-item>
                              <el-descriptions-item >
                                <template slot="label">
                                      联系人地址
                                </template>
                                {{ContactByTelName.conAddress}}
                              </el-descriptions-item>
                      </el-descriptions>
          </el-form>
        </el-collapse-item>
        </el-collapse>
    </el-tab-pane>
      <el-tab-pane label="跟进记录" name="conSecond">
      <el-form ref="FollowRecord" :model="FollowRecord" :rules="rules" label-width="100px">
                <el-table :data="FollowRecord" @selection-change="handleSelectionChange" empty-text="暂无数据">
                  <el-table-column label="主题" align="center" prop="theme"/>
                  <el-table-column label="客户名称" align="center" prop="customerName" />
                  <el-table-column label="联系人姓名" align="center" prop="telName" />
                  <el-table-column label="客户状态" align="center" prop="status" />
                  <el-table-column label="联系方式" align="center" prop="howContact" />
                  <el-table-column label="联系日期" align="center" prop="contactDate" />
                  <el-table-column label="负责人" align="center" prop="staffFollower" />
                  <el-table-column label="跟进记录" align="center" prop="followRecord" />
                  <el-table-column label="最新修改时间" align="center" prop="updateTime" />
                </el-table>
              </el-form>
      </el-tab-pane>
</el-tabs>
     <div slot="footer" class="dialog-footer">
       <el-button type="primary" @click="submitForm2">确 定</el-button>
       <el-button @click="cancel2">取 消</el-button>
     </div>
  </el-dialog>

<el-dialog :title="title" :visible.sync="dialogVisible" width="800px" append-to-body>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="客户详情" name="first">
      <el-collapse v-model="activeNames" @change="handleChange">
        <el-collapse-item title="基本信息" name="1">
       <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
        <el-descriptions class="margin-top"  :column="2" :size="size" border>
          <el-descriptions-item >
            <template slot="label">
                  客户名称
            </template>
            {{CustomerInfo.customerName}}
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
                  上级单位
            </template>
            {{CustomerInfo.superior}}
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
                  客户编号
            </template>
            {{CustomerInfo.customerNo}}
          </el-descriptions-item>
          <el-descriptions-item>
             <template slot="label">
                  客户状态
             </template>
             {{CustomerInfo.customerStatus}}
          </el-descriptions-item>
          <el-descriptions-item>
             <template slot="label">
                  客户类型
             </template>
             {{CustomerInfo.customerType}}
          </el-descriptions-item>
          <el-descriptions-item>
             <template slot="label">
                  销售负责人
             </template>
             {{CustomerInfo.staffFollower}}
          </el-descriptions-item>
          <el-descriptions-item>
             <template slot="label">
                  重要级别
             </template>
             {{CustomerInfo.level}}
          </el-descriptions-item>
          <el-descriptions-item>
             <template slot="label">
                  最新服务时间
             </template>
             {{CustomerInfo.contactDateLast}}
          </el-descriptions-item>
          <el-descriptions-item>
             <template slot="label">
                  最新分配人
             </template>
             {{CustomerInfo.followLast}}
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
                  是否新客户
            </template>
            {{CustomerInfo.isNewCu}}
          </el-descriptions-item>
        </el-descriptions>
       </el-form>
       </el-collapse-item>

        <el-collapse-item title="工商信息" name="2">
        <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
          <el-descriptions class="margin-top"  :column="2" :size="size" border>
                <el-descriptions-item >
                  <template slot="label">
                        纳税人识别号
                  </template>
                  {{CustomerInfo.taxpayerNo}}
                </el-descriptions-item>
                <el-descriptions-item >
                  <template slot="label">
                        注册时间
                  </template>
                  {{CustomerInfo.registerDate}}
                </el-descriptions-item>
                <el-descriptions-item >
                  <template slot="label">
                        公司性质
                  </template>
                  {{CustomerInfo.companyNature}}
                </el-descriptions-item>
                <el-descriptions-item >
                  <template slot="label">
                        客户规模
                  </template>
                  {{CustomerInfo.customerSize}}
                </el-descriptions-item>
                <el-descriptions-item >
                  <template slot="label">
                        法定代表人
                  </template>
                  {{CustomerInfo.legalRepresent}}
                </el-descriptions-item>
                <el-descriptions-item >
                  <template slot="label">
                        注册资金
                  </template>
                  {{CustomerInfo.registerAc}}
                </el-descriptions-item>
                <el-descriptions-item >
                  <template slot="label">
                        所属行业
                  </template>
                  {{CustomerInfo.industry}}
                </el-descriptions-item>
                <el-descriptions-item >
                  <template slot="label">
                        经营范围
                  </template>
                  {{CustomerInfo.businessScope}}
                </el-descriptions-item>
          </el-descriptions>
       </el-form>
        </el-collapse-item>

        <el-collapse-item title="动态信息" name="3">
          <el-form ref="customerList" :model="customerList" :rules="rules" label-width="80px">
            <el-descriptions class="margin-top"  :column="2" :size="size" border>
                    <el-descriptions-item >
                      <template slot="label">
                            下次回访日期
                      </template>
                        {{CustomerInfo.nextRevisitTime}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            未联系天数
                      </template>
                      177
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            最新联系日期
                      </template>
                      {{CustomerInfo.contactDateLast}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            最新进展
                      </template>
                      {{CustomerInfo.lastProgress}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            创建时间
                      </template>
                      {{CustomerInfo.createTime}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            修改时间
                      </template>
                      {{updateTime}}
                    </el-descriptions-item>
            </el-descriptions>
          </el-form>
        </el-collapse-item>

        <el-collapse-item title="首要联系人" name="4">
          <el-form ref="FirstContactInfo" :model="FirstContactInfo" :rules="rules" label-width="80px">
            <el-descriptions class="margin-top"  :column="2" :size="size" border>
                    <el-descriptions-item >
                      <template slot="label">
                            联系人姓名
                      </template>
                      {{FirstContactInfo.telName}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            联系人职务
                      </template>
                      {{FirstContactInfo.position}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            联系人称谓
                      </template>
                      {{FirstContactInfo.conSex}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            办公电话
                      </template>
                      {{FirstContactInfo.officePhone}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            联系人手机
                      </template>
                      {{FirstContactInfo.telephone}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            联系人住址
                      </template>
                      {{FirstContactInfo.conAddress}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            联系人Email
                      </template>
                      {{FirstContactInfo.conEmail}}
                    </el-descriptions-item>
            </el-descriptions>
          </el-form>
        </el-collapse-item>

        <el-collapse-item title="地址信息" name="5">
                  <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                    <el-descriptions class="margin-top"  :column="2" :size="size" border>
                            <el-descriptions-item >
                              <template slot="label">
                                    国家
                              </template>
                              {{CustomerInfo.country}}
                            </el-descriptions-item>
                            <el-descriptions-item >
                              <template slot="label">
                                    省份
                              </template>
                              {{CustomerInfo.province}}
                            </el-descriptions-item>
                            <el-descriptions-item >
                              <template slot="label">
                                    城市
                              </template>
                              {{CustomerInfo.city}}
                            </el-descriptions-item>
                            <el-descriptions-item >
                              <template slot="label">
                                    区域
                              </template>
                              {{CustomerInfo.region}}
                            </el-descriptions-item>
                            <el-descriptions-item >
                              <template slot="label">
                                    详细地址
                              </template>
                              {{CustomerInfo.address}}
                            </el-descriptions-item>
                    </el-descriptions>
                  </el-form>
                </el-collapse-item>

                    <el-collapse-item title="备注信息" name="6">
                  <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                    <el-descriptions class="margin-top"  :column="2" :size="size" border>
                            <el-descriptions-item >
                              <template slot="label">
                                    备注
                              </template>
                              {{CustomerInfo.markInfo}}
                            </el-descriptions-item>
                    </el-descriptions>
                  </el-form>
                 </el-collapse-item>

                 <el-collapse-item title="附件信息" name="7">
                  <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                    <el-descriptions class="margin-top"  :column="2" :size="size" border>
                            <el-descriptions-item >
                              <template slot="label">
                                    附件信息
                              </template>
                              {{CustomerInfo.enclosureInfo}}
                            </el-descriptions-item>
                    </el-descriptions>
                  </el-form>
                 </el-collapse-item>

                 <el-collapse-item title="服务合同信息" name="8">
                  <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                    <el-descriptions class="margin-top"  :column="2" :size="size" border>
                            <el-descriptions-item >
                              <template slot="label">
                                    合同服务信息
                              </template>
                              {{CustomerInfo.serviceContractInfo}}
                            </el-descriptions-item>
                    </el-descriptions>
                  </el-form>
                 </el-collapse-item>

                 <el-collapse-item title="评论信息" name="9">
                  <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                    <el-descriptions class="margin-top"  :column="2" :size="size" border>
                            <el-descriptions-item >
                              <template slot="label">
                                    评论信息
                              </template>
                              {{CustomerInfo.comment}}
                            </el-descriptions-item>
                    </el-descriptions>
                  </el-form>
                 </el-collapse-item>

       </el-collapse>
      </el-tab-pane>

      <el-tab-pane label="联系人" name="10">
        <el-form ref="Contact" :model="Contact" :rules="rules" label-width="100px">
          <el-table :data="Contact" @selection-change="handleSelectionChange" empty-text="暂无数据">
            <el-table-column label="联系人姓名" align="center" prop="telName"/>
            <el-table-column label="联系人编号" align="center" prop="telNo" />
            <el-table-column label="职务" align="center" prop="position" />
            <el-table-column label="手机" align="center" prop="telephone" />
            <el-table-column label="销售负责人" align="center" prop="staffFollower" />
            <el-table-column label="修改时间" align="center" prop="updateTime" />
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-edit"
                  @click="handleUpdate(scope.row)"
                  v-hasPermi="['system:customer:edit']"
                >修改</el-button>
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-delete"
                  @click="handleDelete(scope.row)"
                  v-hasPermi="['system:customer:remove']"
                >删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-form>
      </el-tab-pane>

      <el-tab-pane label="跟进记录" name="11">
      <el-form ref="FollowRecord" :model="FollowRecord" :rules="rules" label-width="100px">
                <el-table :data="FollowRecord" @selection-change="handleSelectionChange" empty-text="暂无数据">
                  <el-table-column label="主题" align="center" prop="theme"/>
                  <el-table-column label="客户名称" align="center" prop="customerName" />
                  <el-table-column label="联系人姓名" align="center" prop="telName" />
                  <el-table-column label="客户状态" align="center" prop="status" />
                  <el-table-column label="联系方式" align="center" prop="howContact" />
                  <el-table-column label="联系日期" align="center" prop="contactDate" />
                  <el-table-column label="负责人" align="center" prop="staffFollower" />
                  <el-table-column label="跟进记录" align="center" prop="followRecord" />
                  <el-table-column label="最新修改时间" align="center" prop="updateTime" />
                </el-table>
              </el-form>
      </el-tab-pane>
</el-tabs>
     <div slot="footer" class="dialog-footer">
       <el-button type="primary" @click="submitForm1">确 定</el-button>
       <el-button @click="cancel1">取 消</el-button>
     </div>
  </el-dialog>

    <!-- 添加或修改联系人对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="联系人姓名" prop="telName">
          <el-input v-model="form.telName" placeholder="请输入联系人姓名" />
        </el-form-item>
        <el-form-item label="客户名称" prop="customerName">
          <el-input v-model="form.customerName" placeholder="请输入客户名称" />
        </el-form-item>
        <el-form-item label="联系人编号" prop="telNo">
          <el-input v-model="form.telNo" placeholder="请输入联系人编号" />
        </el-form-item>
        <el-form-item label="职务" prop="position">
          <el-input v-model="form.position" placeholder="请输入职务" />
        </el-form-item>
        <el-form-item label="手机" prop="telephone">
          <el-input v-model="form.telephone" placeholder="请输入手机" />
        </el-form-item>
        <el-form-item label="销售负责人" prop="staffFollower">
          <el-input v-model="form.staffFollower" placeholder="请输入销售负责人" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listPerson, getPerson, delPerson, addPerson, updatePerson ,getCustomerInfo,getFollowRecord,getContact,getContactByTelName,getFirstContactInfoByCustomerName} from "@/api/crm/contact";

export default {
  name: "Person",
  data() {
    return {
      activeNames: ['1'],
      activeName: 'second',
      // 遮罩层
      loading: true,
      Contact: [],
      ContactObj: {},
      CustomerInfo: {},
      FirstContactInfo: {},
      // 选中数组
      ids: [],
      FollowRecord: [],
      dialogVisible: false,
      contactDialog: false,
      ContactByTelName: {},
      // 非单个禁用
      single: true,
      size: '',
      uncontactDays: '',
      updateTime: '',
      data: {},
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 联系人表格数据
      personList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        telName: null,
        customerName: null,
        telNo: null,
        position: null,
        telephone: null,
        staffFollower: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询联系人列表 */
    getList() {
      this.loading = true;
      listPerson(this.queryParams).then(response => {
        this.personList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
cancel1() {
              this.dialogVisible = false;
              this.reset();
            },
                        cancel2() {
                          this.contactDialog = false;
                          this.reset();
                        },
                                    submitForm1() {
                                      this.dialogVisible = false;
                                      this.reset();
                                    },
                                                submitForm2() {
                                                  this.contactDialog = false;
                                                  this.reset();
                                                },
    getContactInfo(row){
const telName = row.telName;
                        const customerName = row.customerName;

                        this.updateTime= row.updateTime;
                        this.uncontactDays=row.uncontactDays;
              getContactByTelName(telName).then(response => {
                   this.ContactByTelName=response.data;
                   console.log(this.ContactByTelName)
                   this.contactDialog=true;
                   this.size='50';
              })
                    getCustomerInfo(customerName).then(response => {
                        this.CustomerInfo=response.data;
                        console.log(this.CustomerInfo);
                        this.size='50';
                    })
                         getFollowRecord(customerName).then(response => {
                                             let list=response.data;
                                             this.FollowRecord.push(...response.data);
                                             this.size='50';
                         })
    },
                handleChange(val) {
                              },
         handleClick(tab, event) {
              },
getCustomerInfo1(row){
      const customerName = row.customerName;
      this.updateTime= row.updateTime;
      this.uncontactDays=row.uncontactDays;
      getCustomerInfo(customerName).then(response => {
          this.CustomerInfo=response.data;
          this.dialogVisible=true;
          this.title= "客户信息";
          this.size='50';
      })
      getFollowRecord(customerName).then(response => {
                          let list=response.data;
                          this.FollowRecord.push(...response.data);
                          this.dialogVisible=true;
                          this.size='50';
      })
      getContact(customerName).then(response => {
                          this.ContactObj=response.data;
                          let list =response.data;
                          this.Contact.push(...response.data);
                          this.dialogVisible=true;
                          this.size='50';
      })
            getFirstContactInfoByCustomerName(customerName).then(response => {
                this.FirstContactInfo=response.data;
                                this.dialogVisible=true;
                                this.size='50';
            })
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        telName: null,
        customerName: null,
        telNo: null,
        position: null,
        telephone: null,
        staffFollower: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加联系人";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getPerson(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改联系人";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updatePerson(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addPerson(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除联系人编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delPerson(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('crm/person/export', {
        ...this.queryParams
      }, `crm_person.xlsx`)
    }
  }
};
</script>
